home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 501-525 / disk_519 / avlsort / avltree.h < prev    next >
C/C++ Source or Header  |  1992-05-06  |  2KB  |  97 lines

  1. /*
  2.  *    avltree.h        Definitions for avl routines
  3.  *
  4.  *    Copyright 1988 Zinn Computer Company
  5.  *    by Mark E. Mallett
  6.  *    All Rights Reserved
  7.  *
  8.  *    This software may be used at will, provided that all credits
  9.  *    and style be left in place, and that its distribution is not
  10.  *    restricted. Bug fixes and improvements are welcomed, please
  11.  *    send these back to me at mem@zinn.MV.COM
  12.  *
  13.  *    rlp910619 -- sorry, I've modified this to include prototypes
  14.  *            and register arguments.
  15.  */
  16.  
  17. #ifndef    AVLTREE_H        /* prevent multiple inclusions */
  18. #define    AVLTREE_H
  19.  
  20.  /*--------------------------------------------------------------
  21.   * rlp919417 -- Support for Lattice-style register arguments
  22.   *--------------------------------------------------------------
  23.   */
  24.  
  25. #ifndef LATTICE
  26. #define __regargs
  27. #endif
  28.  
  29. #ifndef    TRUE
  30. #define    TRUE    1
  31. #define    FALSE    0
  32. #endif /*TRUE*/
  33.  
  34. #ifndef    NULL
  35. #define    NULL    0L
  36. #endif /*NULL*/
  37.  
  38. #ifndef    NUL
  39. #define    NUL    '\0'
  40. #endif /*NUL*/
  41.  
  42.  /*-------------------------------------------
  43.   * rlp900624 -- added typedefs and prototypes
  44.   *-------------------------------------------
  45.   */
  46.  
  47. typedef struct _AVLNODE AVLNODE;
  48. typedef struct _AVLTREE AVLTREE;
  49.  
  50. AVLNODE    * __regargs avlfind (AVLTREE * treeP, void *keyP);
  51. int      __regargs avlinsert (AVLTREE * treeP, void *keyP, void *dataP);
  52. int      __regargs avldelete (AVLTREE * treeP, void *keyP);
  53.  
  54.  /* Structures */
  55.  
  56. /*
  57.  * Structure of an avl tree node.  Note that this node is meant to be
  58.  * used as a header or component of an application-specific structure,
  59.  * since there is no key or data information present in the avlnode
  60.  * structure.
  61.  */
  62.  
  63. typedef struct _AVLNODE
  64. {
  65.     AVLNODE *n_leftP;    /* Ptr to left subtree */
  66.     AVLNODE *n_rightP;    /* Ptr to right subtree */
  67.     int n_balance;        /* Balance count */
  68. } AVLNODE;
  69.  
  70. /*
  71.  * Header for an AVL tree.
  72.  */
  73.  
  74. typedef struct _AVLTREE
  75. {
  76.     /*
  77.      * Tree parameters
  78.      * t_rootP -- pointer to root node
  79.      */
  80.     AVLNODE *t_rootP;
  81.  
  82.     /*
  83.      * Handler functions for the tree
  84.      * t_cmprtc -- Compare two keys
  85.      * t_mknode -- Create a node
  86.      * t_rmnode -- Destroy a node
  87.      */
  88.  
  89.     int      (* __regargs t_cmprtc) (void*, AVLNODE*);
  90.     AVLNODE *(* __regargs t_mknode) (AVLTREE*, void*, void*, AVLNODE*);
  91.     void     (* __regargs t_rmnode) (AVLTREE*, AVLNODE*);
  92. } AVLTREE;
  93.  
  94. #endif /*AVLTREE_H*/
  95.  
  96.  
  97.